package com.mall.admin.controller;


import com.mall.admin.service.SmsHomeNewProductService;
import com.mall.commons.utils.R;
import com.mall.domain.SmsHomeNewProduct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/home")
public class SmsHomeNewProductController {

    @Autowired
    private SmsHomeNewProductService smsHomeNewProductService;

    //分页查询首页新品
    @GetMapping("/newProduct/list")
    public R findByPage(Integer pageNum,Integer pageSize,String productName,Integer recommendStatus) {
        return smsHomeNewProductService.findByPage(pageNum,pageSize,productName,recommendStatus);
    }

    //批量修改首页新品状态
    @PostMapping("/newProduct/update/recommendStatus")
    public R updateRecommendStatus(@RequestParam("ids") List<Long> ids,@RequestParam("recommendStatus") Integer recommendStatus) {
        return smsHomeNewProductService.updateRecommendStatus(ids,recommendStatus);
    }

    //修改首页新品排序
    @PostMapping("/newProduct/update/sort/{id}")
    public R updateSort(Long id, Integer sort) {
        return smsHomeNewProductService.updateSort(id,sort);
    }

    //批量删除首页新品
    @PostMapping("/newProduct/delete")
    public R delete(@RequestParam("ids") List<Long> ids) {
        return smsHomeNewProductService.delete(ids);
    }

    //添加首页新品
    @PostMapping("/newProduct/create")
    public R addCreate(@RequestBody List<SmsHomeNewProduct> homeNewProductList) {
        return smsHomeNewProductService.addCreate(homeNewProductList);

    }
}
